package org.idea.spring.ioc.container;

import org.idea.spring.ioc.bean.Person;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * @Author linhao
 * @Date created in 3:07 下午 2021/3/12
 */
public class ContextBeanFactory {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext();
        annotationConfigApplicationContext.register(ContextBeanFactory.class);
        annotationConfigApplicationContext.refresh();
        Person person = annotationConfigApplicationContext.getBean(Person.class);
        System.out.println(person);
    }

    @Bean
    public Person person(){
        Person person = new Person();
        person.setId(1);
        person.setName("idea");
        return person;
    }

}
